<template>
  <div class="all">
    <van-nav-bar
      title="我的订单"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="allCart" v-for="item in goodsData" :key="item.id">
      <van-swipe-cell>
        <!-- <van-checkbox v-model="item.checked"></van-checkbox> -->
        <van-card
          :price="item.s_good.price + '.00'"
          desc="描述信息"
          :title="item.s_good.name"
          :thumb="item.s_good.s_goods_photos[0].path"
        >
        </van-card>
      </van-swipe-cell>
    </div>
    <Docker />
  </div>
</template>
<script setup>
import { Toast } from "vant";
import { useRoute } from "vue-router";
import { ref, reactive, defineProps, computed } from "vue";
import { changeNum, delNum, get, getget, getOrderList } from "../utils/request";
import itemVue from "../components/item.vue";
// import { useRouter } from "vue-router";
let route = useRoute();
let params = reactive({ project_id: 248 });
let goodsData = ref([]);

// 请求后台数据;
const getDatas = async () => {
  console.log(sessionStorage.getItem("token"));
  let res = await getget(
    `/shoppingCart?project_id=248`,
    sessionStorage.getItem("token")
  );
  console.log(res);
  goodsData.value = res.result;
  goodsData.value.forEach((ele) => {
    ele.checked = true;
  });
};
getDatas();
// 顶部导航栏
const onClickLeft = () => history.back();
// 删除
const delCart = async (id) => {
  let res = await delNum(`/shoppingCart/${id}`);
  getDatas();
};
// 轻提示
const onSubmit = () => Toast("点击按钮");
// const onClickLink = () => Toast('修改地址');
</script>

<style lang="scss" scoped>
.all {
  padding-bottom: 47px;
}
.allCart {
  padding: 10px;
  display: flex;
  // flex-direction: column;
  justify-content: center;
}
</style>
